package com.framework.disconf.web.action;

import com.framework.disconf.entity.User;
import com.framework.disconf.service.IUserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserAction{

    private static final Logger logger = LoggerFactory.getLogger(UserAction.class);

    @Autowired
    private IUserService userService;

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public void create(@RequestBody User paramBean) {
        userService.create(paramBean);
    }

    @ApiOperation(value = "修改", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "/modifyById", method = RequestMethod.POST)
    public void modifyById(@ApiParam(value = "", required = true) @RequestBody User paramBean) {
        userService.modifyById(paramBean);
    }

    @ApiOperation(value = "根据主键删除", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "deleteById", method = RequestMethod.POST)
    public void deleteById(@ApiParam(value = "id", required = true) @RequestParam Long id) {
        userService.deleteById(id);
    }

    @ApiOperation(value = "根据主键获取", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "getUserById", method = RequestMethod.POST)
    public User getUserById(@ApiParam(value = "id", required = true) @RequestParam Long id) {
        User result = null;
        result = userService.getUserById(id);
        return result;
    }

}